public class Test {
    if(head == null) {
        return null;
    }

    ListNode cur = head.next;
    ListNode curL = head;

        while( cur != null) {
        if(cur.val == val) {
            curL.next = cur.next;
        }else {
            curL = cur;;
        }
        cur = cur.next;
    }

        if(head.val == val) {
        head = head.next;
    }
        return head;
    public ListNode reverseList(ListNode head) {
        if(head == null) {
            return null;
        }
        if(head.next == null) {
            return head;
        }

        ListNode cur = head;
        ListNode curN = head.next;
        head.next = null;


        while(curN != null) {
            ListNode curNN = curN.next;
            curN.next = cur;
            cur = curN;
            curN = curNN;
        }
        return cur;
    }
    public int kthToLast(ListNode head, int k) {
        ListNode fast = head;
        ListNode slow = head;

        int count = k-1;
        while(count != 0) {
            fast = fast.next;
            count--;
        }

        while(fast.next != null) {
            fast = fast.next;
            slow = slow.next;
        }

        return slow.val;

    }
}
